package com.water.camera.mark;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.bean.EditItem;
import com.water.camera.databinding.LayoutWatermark86Binding;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Mark86 extends BaseMark {

    LayoutWatermark86Binding binding;

    public Mark86(@NonNull Context context) {
        super(context);
    }

    public Mark86(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Mark86(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(int type) {
        if (type == 0) {
            binding = LayoutWatermark86Binding.inflate(LayoutInflater.from(getContext()));
            addView(binding.getRoot());
        } else {
            binding = LayoutWatermark86Binding.inflate(LayoutInflater.from(getContext()), this, true);
        }
        update();
    }

    @Override
    public void update() {
        setText(binding.item75Title, "title86", binding.item75Linear);
        setText(binding.binding3, "time86", binding.item75Time);
        setTime(binding.binding5, new SimpleDateFormat("HH:mm"));
        setTime(binding.binding3, new SimpleDateFormat("yyyy/MM/dd"));
        setWeek(binding.binding4);

        setText(binding.item75Address, "didian86", binding.item75Address);
        setText(binding.item75Lalo, "jingwei86", binding.item75Lalo);
        setText(binding.item75Operator, "operator86", binding.item75Operator);


        setText(binding.item75Remark, "beizhu86", binding.item75Remark);

        super.update();
    }

    @Override
    public ArrayList<EditItem> getEditItems() {
        ArrayList<EditItem> list = new ArrayList<>();
        list.add(new EditItem("title86", "标题"));
        list.add(new EditItem("time86", "时间", true));
        list.add(new EditItem("didian86", "地点"));
        list.add(new EditItem("jingwei86", "经纬度"));
        list.add(new EditItem("operator86", "操作员"));
        list.add(new EditItem("beizhu86", "备注"));

        return list;
    }

    @Override
    public void onValueChange(EditItem item) {
        if (item.isTime) {
            setTime(binding.binding5, new SimpleDateFormat("HH:mm"));
            setTime(binding.binding3, new SimpleDateFormat("yyyy/MM/dd"));
            setWeek(binding.binding4);
        } else {
            super.onValueChange(item);
        }
    }
}
